import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import '../../../common/http/global.dart';

class CreatMeListView extends StatelessWidget {
  List data = [];
  CreatMeListView({super.key, required this.data});
  @override
  Widget build(BuildContext context) {
    return MasonryGridView.count(
      padding: const EdgeInsets.all(0),
      itemCount: data.length,
      mainAxisSpacing: 10,
      crossAxisSpacing: 10,
      // itemCount: 10,
      crossAxisCount: 2,
      itemBuilder: (context, index) {
        final Map<String, dynamic> itemData = data[index]; // 获取当前索引对应的data中的元素
        return Container(
          color: Colors.white,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              FadeInImage(
                  placeholder: const AssetImage('assets/images/testphoto.jpg'),
                  image:
                      NetworkImage("$baseImageUrl${itemData['coverImage']}")),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  if (itemData.containsKey("title") && itemData["title"] != "")
                    Padding(
                      padding: const EdgeInsets.only(top: 5),
                      child: Text(itemData['title'],
                          style: const TextStyle(
                              color: Colors.black, fontSize: 15)),
                    ),
                  Padding(
                    padding: const EdgeInsets.only(top: 5, bottom: 5),
                    child: Row(
                      children: [
                        ClipRRect(
                          borderRadius: BorderRadius.circular(15),
                          child: FadeInImage(
                              fit: BoxFit.cover,
                              width: 30,
                              height: 30,
                              placeholder: const AssetImage(
                                  'assets/images/testphoto.jpg'),
                              image: NetworkImage(
                                  "$baseImageUrl${itemData['headImg']}")),
                        ),
                        const SizedBox(width: 5),
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(itemData['name'],
                                style: const TextStyle(
                                  fontSize: 12,
                                  color: Colors.black,
                                )),
                            Text(
                              itemData['creatTime'],
                              style: const TextStyle(
                                fontSize: 12,
                                color: Colors.black54,
                              ),
                            )
                          ],
                        )
                      ],
                    ),
                  )
                ],
              ),
            ],
          ),
        );
      },
    );
  }
}
